-
Notifications
You must be signed in to change notification settings - Fork 594
[JDBC] Connection#createArray
& Connection#createStruct
#2523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements Connection#createStruct
and improves Connection#createArray
to enhance JDBC SQL type support for ClickHouse arrays and tuples.
- Adds support for creating Struct objects from Tuple types
- Improves Array creation with better type handling and validation
- Refactors array encoding logic in PreparedStatement for better maintainability
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
jdbc-v2/src/main/java/com/clickhouse/jdbc/types/Struct.java | New Struct implementation for Tuple types |
jdbc-v2/src/main/java/com/clickhouse/jdbc/types/Array.java | Enhanced Array constructor with better validation |
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java | Implements createStruct and improves createArrayOf methods |
jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java | Refactored object encoding logic with better array/tuple handling |
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java | Updated array conversion utilities |
jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java | Added comprehensive tests for new functionality |
Other files | Minor utility improvements and bug fixes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
||
@Override | ||
public Object[] getAttributes(Map<String, Class<?>> map) throws SQLException { | ||
return attributes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getAttributes(Map) method also returns a direct reference to the internal attributes array, allowing external modification. Consider returning a defensive copy: return attributes.clone();
return attributes; | |
return attributes.clone(); |
Copilot uses AI. Check for mistakes.
final String tableName = "array_create_test"; | ||
final String arrayType = "Array(Array(" + baseType + "))"; | ||
try (Statement stmt = conn.createStatement()) { | ||
stmt.executeUpdate("CREATE TABLE " +tableName + " (v1 " + arrayType + ") ENGINE MergeTree ORDER BY ()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] String concatenation in SQL statements can be error-prone. Consider using String.format() or a StringBuilder for better readability: String.format("CREATE TABLE %s (v1 %s) ENGINE MergeTree ORDER BY ()", tableName, arrayType)
stmt.executeUpdate("CREATE TABLE " +tableName + " (v1 " + arrayType + ") ENGINE MergeTree ORDER BY ()"); | |
stmt.executeUpdate(String.format("CREATE TABLE %s (v1 %s) ENGINE MergeTree ORDER BY ()", tableName, arrayType)); |
Copilot uses AI. Check for mistakes.
|
Summary
Connection#createStruct
Connection#createArray
Closes #2412
Closes #2360
Checklist
Delete items not relevant to your PR: